import request from '@/utils/request'

export function alarms(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/alarm' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/alarm' + url,
      method: method,
      params
    })
  }
}
export function events(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/event' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/event' + url,
      method: method,
      params
    })
  }
}
export function logLevel(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/loglevel' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/loglevel' + url,
      method: method,
      params
    })
  }
}

export function logExtrace(url, method, params) {
  return request({
    url: '/api/logextraction' + url,
    method: method,
    data: params,
    timeout:4*60*1000,//4分钟
  })
}

export function advertise(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/appletAd' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/appletAd' + url,
      method: method,
      params
    })
  }
}
export function userSemaphoreSub(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/userSemaphoreSub' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/userSemaphoreSub' + url,
      method: method,
      params
    })
  }
}
export function semaphore(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/semaphore' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/semaphore' + url,
      method: method,
      params
    })
  }
}

export function product(url, method, params, type) {
    if (type == 1) {
        return request({
            url: '/api/product' + url,
            method: method || 'post',
            data: params
        })
    } else if (type == 2){
        return request({
            url: '/api/product' + url,
            method: method || 'post',
            responseType: 'blob',
            params
        })
    } else {
        return request({
            url: '/api/product' + url,
            method: method || 'post',
            params
        })
    }
}
// 广告管理
export function advertiseManage(url, method, params, type) {
  if (type == 1) {
    return request({
      url: '/api/equipAdFile' + url,
      method: method,
      data: params
    })
  } else {
    return request({
      url: '/api/equipAdFile' + url,
      method: method,
      params
    })
  }
}